package com.gxa.service.impl;

import com.gxa.common.PaginationResult;
import com.gxa.mapper.StoneMapper;
import com.gxa.pojo.*;
import com.gxa.service.StoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: zxy
 * Date: 2020/10/29 10:20
 * Description:
 * Version: V1.0
 */
@Service
public class StoneServiceImpl implements StoneService{

    @Autowired(required = false)
    private StoneMapper stoneMapper;

    @Override
    public int addStoneStyle(StoneType stoneType) {
        return stoneMapper.addStoneStyle(stoneType);
    }
    @Override
    public PaginationResult queryStoneType(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneType();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneType> stoneTypeList =  stoneMapper.queryStoneType(param1,param2);
        paginationResult.setData(stoneTypeList);
        return paginationResult;
    }
    @Override
    public int updateStoneStyle(StoneType stoneType) {
        return stoneMapper.updateStoneStyle(stoneType);
    }
    @Override
    public int delStoneStyle(int typeId) {
        return stoneMapper.delStoneStyle(typeId);
    }


    @Override
    public int addStoneColor(StoneColor stoneColor) {
        return stoneMapper.addStoneColor(stoneColor);
    }
    @Override
    public PaginationResult queryStoneColor(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneColor();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneColor> stoneColorList =  stoneMapper.queryStoneColor(param1,param2);
        paginationResult.setData(stoneColorList);
        return paginationResult;
    }
    @Override
    public int updateStoneColor(StoneColor stoneColor) {
        return stoneMapper.updateStoneColor(stoneColor);
    }
    @Override
    public int delStoneColor(int colorId) {
        return stoneMapper.delStoneColor(colorId);
    }


    @Override
    public int addStoneClarity(StoneClarity stoneClarity) {
        return stoneMapper.addStoneClarity(stoneClarity);
    }
    @Override
    public PaginationResult queryStoneClarity(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneClarity();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneClarity> stoneClarityList =  stoneMapper.queryStoneClarity(param1,param2);
        paginationResult.setData(stoneClarityList);
        return paginationResult;
    }
    @Override
    public int updateStoneClarity(StoneClarity stoneClarity) {
        return stoneMapper.updateStoneClarity(stoneClarity);
    }
    @Override
    public int delStoneClarity(int clarityId) {
        return stoneMapper.delStoneClarity(clarityId);
    }


    @Override
    public int addStoneCut(StoneCut stoneCut) {
        return stoneMapper.addStoneCut(stoneCut);
    }
    @Override
    public PaginationResult queryStoneCut(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneCut();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneCut> stoneCutList =  stoneMapper.queryStoneCut(param1,param2);
        paginationResult.setData(stoneCutList);
        return paginationResult;
    }
    @Override
    public int updateStoneCut(StoneCut stoneCut) {
        return stoneMapper.updateStoneCut(stoneCut);
    }
    @Override
    public int delStoneCut(int cutId) {
        return stoneMapper.delStoneCut(cutId);
    }


    @Override
    public int addStoneSci(StoneSci stoneSci) {
        return stoneMapper.addStoneSci(stoneSci);
    }
    @Override
    public PaginationResult queryStoneSci(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneSci();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneSci> stoneSciList =  stoneMapper.queryStoneSci(param1,param2);
        paginationResult.setData(stoneSciList);
        return paginationResult;
    }
    @Override
    public int updateStoneSci(StoneSci stoneSci) {
        return stoneMapper.updateStoneSci(stoneSci);
    }
    @Override
    public int delStoneSci(int sciId) {
        return stoneMapper.delStoneSci(sciId);
    }


    @Override
    public int addStoneShape(StoneShape stoneShape) {
        return stoneMapper.addStoneShape(stoneShape);
    }
    @Override
    public PaginationResult queryStoneShape(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneShape();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneShape> stoneShapeList =  stoneMapper.queryStoneShape(param1,param2);
        paginationResult.setData(stoneShapeList);
        return paginationResult;
    }
    @Override
    public int updateStoneShape(StoneShape stoneShape) {
        return stoneMapper.updateStoneShape(stoneShape);
    }
    @Override
    public int delStoneShape(int shapeId) {
        return stoneMapper.delStoneShape(shapeId);
    }


    @Override
    public int addStoneNorms(StoneNorms stoneNorms) {
        return stoneMapper.addStoneNorms(stoneNorms);
    }
    @Override
    public PaginationResult queryStoneNorms(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneNorms();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneNorms> stoneNormsList =  stoneMapper.queryStoneNorms(param1,param2);
        paginationResult.setData(stoneNormsList);
        return paginationResult;
    }
    @Override
    public int updateStoneNorms(StoneNorms stoneNorms) {
        return stoneMapper.updateStoneNorms(stoneNorms);
    }
    @Override
    public int delStoneNorms(int normsId) {
        return stoneMapper.delStoneNorms(normsId);
    }


    @Override
    public int addStoneTexture(StoneTexture stoneTexture) {
        return stoneMapper.addStoneTexture(stoneTexture);
    }
    @Override
    public PaginationResult queryStoneTexture(int currentPage,int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneTexture();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneTexture> stoneTextureList =  stoneMapper.queryStoneTexture(param1,param2);
        paginationResult.setData(stoneTextureList);
        return paginationResult;
    }
    @Override
    public int updateStoneTexture(StoneTexture stoneTexture) {
        return stoneMapper.updateStoneTexture(stoneTexture);
    }
    @Override
    public int delStoneTexture(int textureId) {
        return stoneMapper.delStoneTexture(textureId);
    }


    @Override
    public int addStoneHead(StoneHead stoneHead) {
        return stoneMapper.addStoneHead(stoneHead);
    }
    @Override
    public PaginationResult queryStoneHead(int currentPage, int pageSize) {
        PaginationResult paginationResult = new PaginationResult();
        //当前页码数
        paginationResult.setCurrentPage(currentPage);
        //每页显示条数
        paginationResult.setPageSize(pageSize);
        //总条数
        int totalSize = getTotalSizeStoneHead();
        //总页数
        int totalPage = totalSize / pageSize;
        if(totalSize % pageSize !=0){
            totalPage +=1;
        }
        paginationResult.setTotalPage(totalPage);
        paginationResult.setTotalSize(totalSize);
        int param1 = (currentPage-1)*pageSize;
        int param2 = pageSize;
        List<StoneHead> stoneHeadList =  stoneMapper.queryStoneHead(param1,param2);
        paginationResult.setData(stoneHeadList);
        return paginationResult;
    }
    @Override
    public int updateStoneHead(StoneHead stoneHead) {
        return stoneMapper.updateStoneHead(stoneHead);
    }
    @Override
    public int delStoneHead(StoneHead stoneHead) {
        return stoneMapper.delStoneHead(stoneHead);
    }


    private int getTotalSizeStoneType() {
        return stoneMapper.getTotalSizeStoneType();
    }
    private int getTotalSizeStoneColor() {
        return stoneMapper.getTotalSizeStoneColor();
    }
    private int getTotalSizeStoneClarity() {
        return stoneMapper.getTotalSizeStoneClarity();
    }
    private int getTotalSizeStoneCut() {
        return stoneMapper.getTotalSizeStoneCut();
    }
    private int getTotalSizeStoneSci() {
        return stoneMapper.getTotalSizeStoneSci();
    }
    private int getTotalSizeStoneShape() {
        return stoneMapper.getTotalSizeStoneShape();
    }
    private int getTotalSizeStoneNorms() {
        return stoneMapper.getTotalSizeStoneNorms();
    }
    private int getTotalSizeStoneTexture() {
        return stoneMapper.getTotalSizeStoneTexture();
    }
    private int getTotalSizeStoneHead() {
        return stoneMapper.getTotalSizeStoneHead();
    }


}
